package config

import (
	"github.com/spf13/viper"
)

type Config struct {
	ServerPort      string
	AccessKeyID     string
	AccessKeySecret string
	SignName        string
	TemplateCode    string
	RedisAddr       string
	RedisPassword   string
	PostgresqlDsn   string
	AlismsEnable    bool
}

func LoadConfig() *Config {
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath(".")

	if err := viper.ReadInConfig(); err != nil {
		panic(err)
	}

	var cfg Config
	if err := viper.Unmarshal(&cfg); err != nil {
		panic(err)
	}

	return &cfg
}
